<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
		<h:form>  
			<p:growl /> 
			<h:panelGrid columns="2" style="width: 100%" columnClasses="gridCellMiddleLeftAligned, gridCellMiddleRightAligned">
				<h:outputText value="User Dashboard" styleClass="outputTextTitle" />
				<h:panelGroup>
				<p:commandLink id="downloadLink" value="User manual" actionListener="#{wAMUserDashboardBean.downloadAction}" ajax="false" style="text-decoration: none; font-size: 1.2em; padding: 4px 10px; cursor: pointer; MARGIN-RIGHT: 2px; color: #333; text-shadow: 0px 1px 0px rgb(255,255,255); font-weight: bold; background-color: #d9d9d9; -moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;">  
				    <p:fileDownload value="#{wAMUserDashboardBean.file}" />  
				</p:commandLink>  
				
				<p:commandLink value="Important Note(s)" onclick="importantNotesList.show()" style="text-decoration: none; font-size: 1.2em; padding: 4px 10px; cursor: pointer; MARGIN-RIGHT: 2px; color: #333; text-shadow: 0px 1px 0px rgb(255,255,255); font-weight: bold; background-color: #d9d9d9; -moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;" />  
				<p:dialog widgetVar="importantNotesList" showHeader="false"	resizable="false" draggable="true">
				   <h:panelGrid>						
						<h:outputLabel value="Important Note(s)"  style="float: left;" styleClass="outputTextSubTitle"  />
							
							<p:dataList value="#{wAMUserDashboardBean.activeNotes}" var="note" 
								type="unordered" itemType="none">
								<p:column>
									<h:panelGrid cellspacing="5" cellpadding="5" columns="4" style="" columnClasses="gridCellTopLeftAligned, gridCellTopLeftAligned, gridCellTopLeftAligned, gridCell400pxTopLeftAligned">
										<h:outputText value=" #{note.sno}  " />
										<h:outputText value=" . " />
										<p:spacer style="width: 5px;" />
										<h:outputText value="  #{note.note}" />	
									</h:panelGrid>								
								</p:column>
							</p:dataList>	
							
							<h:panelGroup style="float:right">
								<p:commandButton onclick="importantNotesList.hide()" value="Close"></p:commandButton>
							</h:panelGroup>
						</h:panelGrid>											
					</p:dialog>					
				</h:panelGroup>
			</h:panelGrid>
			
			<h:panelGrid columns="1" style="width: 100%;">
				<h:outputText value="Notifications" styleClass="outputTextSubTitle" rendered="#{wAMUserDashboardBean.NOTIFICATION_FOUND}" />
				<p:dataList value="#{wAMUserDashboardBean.notificationItems}" var="item" style="width: 100%; border: 1px solid red;" 
							type="unordered" itemType="none" rendered="#{wAMUserDashboardBean.NOTIFICATION_FOUND}">
					<p:column>
						<h:panelGrid columns="2" style="padding: 0 10px; width:100%; -moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px; border-bottom: 1px solid #d9d9d9;" styleClass="datalistGrid" cellspacing="5" columnClasses="gridCellMiddleLeftAligned, gridCellMiddleRightAligned">
							<h:panelGrid columns="2">
								<h:outputText value="#{item.dashboardItem}" />
								<h:panelGrid columns="6">
									<h:outputText value=" #{item.employeeLeave.leaveType.displayname} " style="color: #888888" />
									<p:spacer />
									<h:outputText value="#{item.employeeLeave.periodFrom}" style="color: #888888">
										<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{wAMUserDashboardBean.timeZone}" />
									</h:outputText>
									<h:outputText value=" to " style="color: #888888" />
										
									<h:outputText value="#{item.employeeLeave.periodFrom}" style="color: #888888" >
										<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{wAMUserDashboardBean.timeZone}" />
									</h:outputText>
									
								</h:panelGrid>
							</h:panelGrid>
							
							<h:panelGrid columns="2" columnClasses="gridCellMiddleRightAligned, gridCellMiddleRightAligned" style="float: right; "> 
								<h:panelGroup>
									<h:outputText value="Comment" id="comment" style="cursor: pointer; color: #888888; text-shadow: 0px 1px 0px rgb(255,255,255);" /> 
									<p:tooltip for="comment">
										<h:panelGrid columns="1" columnClasses="gridCellMiddleLeftAligned, gridCellMiddleLeftAligned">
											<h:outputText value="Approved/Rejected by: " style="font-weight: bold" />
											<h:outputText value="#{item.employeeLeave.approver.firstName} #{item.employeeLeave.approver.lastName}" />
											 <h:outputText value="Comment: " style="font-weight: bold"/>
											 <h:outputText value="#{item.employeeLeave.approvalComments}" />
										</h:panelGrid>
									</p:tooltip>
								</h:panelGroup>	
								<p:commandButton icon="ui-icon-close" style="margin-left: 20px;" action="#{wAMUserDashboardBean.deleteDashboardItemActionListener}" update="@form" title="Delete this notification">
									<f:setPropertyActionListener  target="#{wAMUserDashboardBean.selectedDashboardItem}" value="#{item}" />
								</p:commandButton> 
							</h:panelGrid>
						</h:panelGrid>        					
			       	</p:column>
	           		  
				</p:dataList>
				<h:panelGrid rendered="#{wAMUserDashboardBean.NOTIFICATION_FOUND}" style="margin-top: 10px;" >
				</h:panelGrid>  
				<h:outputText value="Requests awaiting approval" styleClass="outputTextSubTitle" />
				
				<p:dataList value="#{wAMUserDashboardBean.dashboardItems}" var="item" style="width: 100%; border: 1px solid red; margin-bottom: 10px;" 
							type="unordered" itemType="none" >
					<p:column>
						<h:panelGrid columns="2" style="padding: 0 10px; width:100%; -moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px; border-bottom: 1px solid #d9d9d9;" styleClass="datalistGrid" cellspacing="5" columnClasses="gridCellMiddleLeftAligned, gridCellMiddleRightAligned">
							<h:outputText value="#{item.dashboardItem}" />
							<h:panelGrid columns="2" columnClasses="gridCellMiddleRightAligned, gridCellMiddleRightAligned" style="float: right; "> 
								<h:outputText value="#{item.itemCount}" style="font-size: 1.2em; font-weight: bold; color: #777777;" />
								<p:commandButton value="Show" style="margin-left: 20px;" action="#{wAMUserDashboardBean.showActionListener}" disabled="#{item.itemCount eq 0}">
									<f:setPropertyActionListener  target="#{wAMUserDashboardBean.selectedDashboardItem}" value="#{item}" />
								</p:commandButton> 
							</h:panelGrid>
						</h:panelGrid>        					
			       	</p:column>
	           		  
				</p:dataList>
				

			</h:panelGrid>			
		</h:form>
	</ui:define>
</ui:composition>